<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="java.util.List" %>
<%@ page import="member.*" %>
<%@ page import="shared.PMF" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>點數交換網</title>

<style>

    /* START - toptop menu */

ul#TTPM

{

    list-style: none;

    float: left;

    margin:0px;

    padding:0px;

}



ul#TTPM li ul {

    display: none;

}

ul#TTPM li

{

    list-style: none;

    font-weight:bold;

}

ul#TTPM li:hover > ul {

    display: block;

    position:absolute;

    z-index:500;

    padding:0px;

} 

/* END - toptop menu */

    </style>
    
<style type="text/css">

.tablein {
	font-size: 36px;
	color: #CCC;
	background-color: #000;
}
.tableins {
	font-size: 36px;
	color: #CCC;
	background-color: #000;
	color: #CC3333;
}
.title {
	font-size: 70px;
	font-weight: bolder;
	color: #000;
}
a {text-decoration: none;
	 color: #000;
} 
.tabletits {
	font-size: 36px;
	color: #FFFFFF;
	border-top-color: #000;
	border-right-color: #000;
	border-bottom-color: #000;
	border-left-color: #000;
	text-decoration: none;
	text-align: center;
}
.tabletit {
	font-size: 36px;
	color: #000;
	border-top-color: #000;
	border-right-color: #000;
	border-bottom-color: #000;
	border-left-color: #000;
	text-decoration: none;
}
body {
	background-color: #99C;
}
.tableCon {
	color: #00F;
	text-decoration: underline;
}
</style></head>

<body>
<table width="1038" height="667" border="0" align="center">
  <tr>
    <th height="188" colspan="4" rowspan="2" class="title" scope="col">會員管理</th>
    <th width="208" height="188" scope="col" align="left">
    <%
	UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    String userName = "";
    boolean intiLogin = true;
    if (user != null) {
	    	userName = user.getNickname();
	    %>
	    <p>您目前是以 <u><%= userName %></u>登入<br>
	        如果這不是您的帳號</p>
	    <p>您可以<u><a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">登出</a></u>，再重新登入！</p>
		<p><u><a href="/mem/editMem01.jsp"><span class="tabletx">修改會員資料</span></a></u></p>
		<%
		//if是管理員印出管理頁面的圖示
	    PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(Member.class);
		query.setFilter("transTimes >= 0");
		try {
		    List<Member> results = (List<Member>) query.execute(userName);
		    if (!results.isEmpty()) {
		    	for (Member p : results) {
		    		if(userName.equals(p.getName())){
		    			if(p.getRequirement() == true){
			    			%>
			    		    <div id="apDiv1"><a href="admminpg.jsp"><img src="../adminIcon.png" width="87" height="105" /></a></div></th>
			    		    <%
			    		    break;
			    		}
					}
		    	}
		    } else {
		    	out.println("無會員資料!");
		    }
		} finally {
		    query.closeAll();
		    pm.close();
		}		
	
    } else {
    	%>
    		<p>請
    		<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">登入</a>,
    		以便開始點數交換</p>
    	<%
        }
	
    
    
	    
    
    //END
    %>
    </th>
  </tr>
  <tr>
   <td><p><a href="index_un.jsp" class="accept">回首頁</a></p></td>
  </tr>
  <tr>
    <th colspan="4" scope="row">&nbsp;</th>
    <td>&nbsp;</td>
  </tr>
  <tr>
      <th width="202" height="133" bgcolor="#0066FF" class="tabletits" scope="row">
    <ul id="TTPM">

        <li id="TTPMI">我的活動

            <ul>

                <li><a href="StrtPg.jsp" ><span class="tablein">發起</span></a></li>

                <li><a href="Attend.jsp" ><span class="tableins">參與</span></a></li>


            </ul>

        </li>

    </ul></th>
    <th width="202" bgcolor="#CC66CC" scope="row"><a href="../record.jsp" class="tabletit" >交易紀錄</a></th>
    <th width="202" bgcolor="#FFFF33" scope="row"><a href="../MyInv.jsp" class="tabletit">我的邀請</a></th>
    <th width="202" bgcolor="#CC3333" class=" scope="row"><a href="../mesg.jsp" class="tabletit">留言</a></th>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th height="21" colspan="5" bgcolor="#000000" scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th  height="55" scope="row">日期</th>
    <th  height="55" scope="row">活動名稱</th>
    <th  height="55" scope="row">條件</th>
    <th height="55" scope="row">截止日</th>
    <td class="tabletit" >&nbsp;</td>
  </tr>
  <tr>
    <th height="53" scope="row">2012-11- 20</th>
    <th height="53" scope="row">7-11 靴下貓生活妙妙夾</th>
    <th height="53" scope="row">2點</th>
    <th height="53" scope="row">2012-12-22</th>
    <td class="tabletit" >&nbsp;</td>
  </tr>
  <tr>
    <th height="58" scope="row">2012-11-27</th>
    <th height="58" scope="row">7-11 海賊王 炫光公仔</th>
    <th height="58" scope="row">2點</th>
    <th height="58" scope="row">2012-12-16</th>
    <td rowspan="2" >&nbsp;</td>
  </tr>
  <tr>
    <th height="53" colspan="4" class="tableCon" scope="row">&nbsp;</th>
  </tr>
</table>
</body>
</html>